﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

#endregion

namespace AutoFormatter
{
    public class Bold : HtmlType
    {
        public Bold():base("b","b") { }
    }
    public class Italic : HtmlType
    {
        public Italic():base("i","i") { }
    }
    public class Underline : HtmlType
    {
        public Underline():base("u","ul","ulnone") { }
    }

    public abstract class AssignType:HtmlType
    {
        string name;
        public AssignType(string name, string openrtf):base(name,openrtf)
        {
            this.name = name;
        }

        protected override void  Addvalue(StringBuilder sb)
        {
            sb.Append("=");
            Append(sb);
        }

        protected abstract void Append(StringBuilder sb);
    }


    public class FontColor : AssignType
    {
        public FontColor(List<Color> Schema):base("FONT Color","cf")
        {
            cols = new string[Schema.Count];
            for (int i = 0; i < Schema.Count; i++)
            {
                cols[i] = html.ColToHex(Schema[i]);
            }
        }

        protected override void  Append(StringBuilder sb)
        {
            if (cols == null) throw new Exception("Colour schema could not be found");
            sb.Append(cols[value - 1]);
        }

        readonly string[] cols;
    }

    public class FontType : HtmlType 
    {
        public FontType(int Language)
            : base("SPAN", "f")
        {
            this.Language = Language;
            kwclose = null;
        }

        readonly int Language;

        public struct FontInfo
        {
            public string FontFamily;
        }

        List<FontInfo> info = new List<FontInfo>();
        public void AddInfo(FontInfo fi)
        {
            info.Add(fi);
        }

        protected override void Addvalue(StringBuilder sb)
        {
            if (value < 0 || value >= info.Count)
                throw new Exception("Invalid font information!");
            FontInfo fi = info[value];
            sb.Append(" style='font-family:")
                .Append(fi.FontFamily)
                .Append("'");
        }
    }

}
